package low;

import java.util.Arrays;

/**
 * 167. 两数之和 II - 输入有序数组
 */
public class TwoSum {
    public static void main(String[] args) {
        int[] nums = new int[]{0,1,3,6,10};
        int[] arrays = twoSum(nums,7);
        System.out.println(Arrays.toString(arrays));
    }

    public static int[] twoSum(int[] nums,int target) {
        int[] res = new int[2];
        for (int i=0;i< nums.length;i++){
            for (int j=i+1;j< nums.length;j++){
                if (nums[i]+nums[j]==target){
                    res[0] = i+1;
                    res[1] = j+1;
                    return res;
                }else if (nums[i]+nums[j]>target){
                    break;
                }
            }
        }
        return res;
    }
}
